//
//  UIBarButtonItem+Category.swift
//  WeiBo
//
//  Created by Gao on 16/3/3.
//  Copyright © 2016年 Gao. All rights reserved.
//

import UIKit

extension UIBarButtonItem
{
    class func createBarButtonItem(imageName: String,target: AnyObject?, action: Selector) -> UIBarButtonItem
    {
        let button = UIButton()
            button.setImage(UIImage(named: imageName), forState: .Normal)
            button.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
            button.sizeToFit()
            button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        return UIBarButtonItem(customView: button)
    }
}
